import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import rmi.Connection;
import rmi.Discussion;
import rmi.Me;
import rmi.Message;

/**
 * @author arthur
 * 
 */
public class testEnvoisMessageRecepteur {

	/**
	 * @param args
	 * @throws AlreadyBoundException
	 */
	public static void main(final String[] args) throws RemoteException,
			MalformedURLException, NotBoundException, InterruptedException,
			AlreadyBoundException {
		final Registry r = LocateRegistry.createRegistry(1099);
		final Me me = new Me("ArthurRecepteur", "localhost", 1099);

		final Connection c = new Connection(2000, r, me);
		r.bind("connection", c);

		Thread.sleep(10000);

		System.out.println("Message");
		for (final Discussion d : me.getCurrentDiscussions()) {
			System.out.println("Discution id :" + d.getId());
			for (final Message mes : d.getListMessages()) {
				System.out.println("Message id :" + mes.getId() + "\n"
						+ mes.getMessage());
			}
		}

		/*
		 * while(true){
		 * //System.out.println("Nombre d'amis connecté :"+me.getConnectedFriends
		 * ().size()); //Thread.sleep(1000); }
		 */

	}

}
